package com.huaguoguo.cyg.webmagic;

import cn.hutool.core.util.StrUtil;
import com.huaguoguo.cyg.converter.StringActionDataConverter;
import com.huaguoguo.cyg.entity.weibo.to.WBDetail;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.nodes.Document;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;
import us.codecraft.xsoup.Xsoup;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 类说明： 按用户爬取微博信息<br/>
 * author:huaguoguo
 * Date: 2019/8/17
 * Time: 14:53
 */
@Slf4j
public class WeiboUserProcessor implements PageProcessor {
    private Site site = Site
            .me()
            .setSleepTime(3000)
            .addHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3")
            .addHeader("Cookie","SINAGLOBAL=4021507592242.448.1569427842132; SCF=Ajb-d2xe1tMm_4hCXJ82l-Hrv9TYTvDI5zviZ-mtGN86GV-DcpoZamnMmHYenTRX89raRiYSj3xV8t90e3JRTPU.; SUHB=0idbENUTouOZ8g; ALF=1607707610; Ugrow-G0=1ac418838b431e81ff2d99457147068c; SUB=_2AkMpReXpf8NxqwJRmP0Wy2jmbox-yA3EieKfGRQyJRMxHRl-yT92qmcEtRB6AsXLBYWu3u9Ug7e97eJb81St0xClgsFY; SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9WFIjy5qxrRL6upyewwYEGRz; login_sid_t=3a65de77a0a34bd25122cd0c0e4b2707; cross_origin_proto=SSL; YF-V5-G0=27518b2dd3c605fe277ffc0b4f0575b3; _s_tentry=passport.weibo.com; UOR=,,www.baidu.com; wb_view_log=2560*14401; Apache=402580356055.0956.1578724065728; ULV=1578724065737:6:1:1:402580356055.0956.1578724065728:1574944404411; YF-Page-G0=96c3bfa80dc53c34a567607076bb434e|1578743802|1578743511")
            .setUserAgent(
                    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31");

    @Override
    public void process(Page page) {

    }

    @Override
    public Site getSite() {
        return site;
    }

    public static void main(String[] args) {
        Spider.create(new WeiboUserProcessor())
//                .setDownloader(new FixPhantonJSDownloader())
                .addUrl("http://weibo.com/p/aj/v6/mblog/mbloglist?ajwvr=6&domain=100505&pagebar=1&id=1005051876856920&page=1&pre_page=1&__rnd=1578734063829")
                .run();


    }
}
